package cn.demomaster.quickui_sample.ui.activity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import cn.demomaster.quickui.helper.QuickTimer;
import cn.demomaster.quickui_sample.R;
import cn.demomaster.quickui.util.StringVerifyUtil;

public class RegisterActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        initView();
    }
    QuickTimer quickTimer;
    private void initView() {
        final EditText et_phone = findViewById(R.id.et_phone);
        final Button btn_get_smscode = findViewById(R.id.btn_get_smscode);
        quickTimer = new QuickTimer(60, time -> btn_get_smscode.setText("剩余"+time));
        btn_get_smscode.setOnClickListener(v -> {
            boolean b = StringVerifyUtil.validatePhone(et_phone.getText().toString());
            if(b){
                Toast.makeText(RegisterActivity.this,"net获取验证码...",Toast.LENGTH_LONG).show();
                quickTimer.stop();

            }else {
                Toast.makeText(RegisterActivity.this,"手机号格式有误",Toast.LENGTH_LONG).show();
            }
        });
    }
}
